//
//  CompanyListCell.swift
//  SBSafetyApp
//
//  Created by Lina on 2023/11/28.
//

import Foundation
import UIKit

class CompanyListCell: UITableViewCell {
    let selectIV = UIImageView()
    let nameL = UILabel()
    let contentL = UILabel()

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: .default, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func reload(withModal modal: CompanyModal?) {
        nameL.text = modal?.gcsmc
        contentL.text = "负责人：\(modal?.gcsfzr ?? "")   电话：\(modal?.gcsfzrlxdh ?? "")"
    }
    
    func setupUI() {
        nameL.textColor = .hex("#333333")
        nameL.font = .systemFont(ofSize: 17)
        addSubview(nameL)
        nameL.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(10)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
        }
        
        contentL.font = .systemFont(ofSize: 15)
        contentL.textColor = .hex("#999999")
        addSubview(contentL)
        contentL.snp.makeConstraints { make in
            make.top.equalTo(nameL.snp.bottom).offset(6)
            make.left.equalTo(nameL.snp.left)
            make.right.equalTo(nameL.snp.right)
        }
        
        addSubview(line)
        line.snp.makeConstraints { (make) -> Void in
            make.top.equalTo(contentL.snp.bottom).offset(10)
            make.bottom.equalToSuperview()
            make.left.equalTo(nameL.snp.left)
            make.right.equalTo(nameL.snp.right)
            make.height.equalTo(0.5)
        }
    }
    
    override func setHighlighted(_ highlighted: Bool, animated: Bool) {
        super.setHighlighted(highlighted, animated: animated)
        if highlighted {
            backgroundColor = .hex("#ECECEC")
        } else {
            backgroundColor = .white
        }
    }
    
    lazy var line: UIView = {
        let li = UIView()
        li.backgroundColor = .hex("#ECECEC")
        return li
    }()
}


